package com.aaa.ssm.controller;

import com.aaa.ssm.entity.TDicArea;
import com.aaa.ssm.service.TDicAreaService;
import com.aaa.ssm.util.Page;
import com.aaa.ssm.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("tDicArea")
public class TDicAreaController extends BaseController{
    @Resource
    private TDicAreaService tDicAreaService;

    /**
     * 分页查询
     * @param page
     * @return
     */
    @PostMapping("queryPage")
    public Result queryPage(@RequestBody Page<TDicArea> page){
        return success(tDicAreaService.queryByParam(page));
    }

    @PostMapping("queryAll")
    public Result queryAll(@RequestBody TDicArea tDicArea){
        return success(tDicAreaService.queryAll(tDicArea));
    }

    //根据编号查询对象
    @GetMapping("queryById")
    public Result queryById(Integer code){
        return success(tDicAreaService.queryById(code));
    }

    //添加
    @PostMapping("add")
    public Result add(@RequestBody TDicArea tDicArea){
        return success(tDicAreaService.add(tDicArea));
    }

    //更新
    @PostMapping("update")
    public Result update(@RequestBody TDicArea tDicArea){
        return success(tDicAreaService.update(tDicArea));
    }

    //删除
    @DeleteMapping("delete/{code}")
    public Result delete(@PathVariable("code") Integer code){
        return success(tDicAreaService.deleteById(code));
    }
}